package cn.tedu.io.file;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class FileInputStreamDemo {
    public static void main(String[] args) throws IOException {
        //创建文件字节输入流对象
        FileInputStream fis=new FileInputStream("D:\\a.txt");

        //读取数据
        //每次读取一个字节返回对应的编码值
        //如果读取结束返回-1
        //System.out.println(fis.read());

        //自建缓冲区---新建数组
        byte[] bs=new byte[8];
        int len=-1;
        //返回的是读取到字节个数，结束条件返回-1
        while ((len=fis.read(bs))!=-1){
            System.out.println(new String(bs,0,len));
        }

        //关流
        fis.close();
    }
}
